package com.example.soa2.common;

public class ResponseEntity<T> {

    private T data; //响应数据
    private int status; //响应状态码
    private String message; //响应消息

    public ResponseEntity(T data, int status, String message) {
        this.data = data;
        this.status = status;
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public int getStatus() {
        return status;
    }

    public String getMessage() {
        return message;
    }

    //静态方法，用于快速创建常用的响应对象
    public static <T> ResponseEntity<T> ok(T data) {
        return new ResponseEntity<>(data, 200, "OK");
    }

    public static <T> ResponseEntity<T> notFound(String message) {
        return new ResponseEntity<>(null, 404, message);
    }

    public static <T> ResponseEntity<T> badRequest(String message) {
        return new ResponseEntity<>(null, 400, message);
    }

    //其他方法省略
}